package com.swj.demo.enums;


import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang.StringUtils;

/**
 * write something please~
 *
 * @author huangrz
 * @since 2021/10/28
 **/
@Getter
@AllArgsConstructor
public enum DemoEnum {

    /**
     * 这是一个枚举值
     */
    DEMO("demo");

    private final String code;

    @JsonCreator
    public static DemoEnum get(String code) {
        if (StringUtils.isEmpty(code)) {
            return null;
        }
        for (DemoEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

}
